﻿/// <reference path="jquery-1.8.1-vsdoc.js" />

/// <reference path="cui-core.js" />

//Define current page object
function demonPage() {
    var self = this;

    //Inherit the CUIpage
    CUIPage.call(this);

    //initial change event
    this.pageEvent["onchanged"] = function (e) {
    };

    //initial submit event
    this.pageEvent["submit"] = function () {
        var x = $("#demosubmit").submitValidate();
        if (x !== null) {
            var temp = "";
            $.each(x, function (key, value) {
                temp += String.stringFormat("[{0} : {1}] ", key, value);
            });
            $("#inputText").text(temp);
            self.sidebarRight.show();
        }
    };

    //validate error event
    this.pageEvent["error"] = function () {
        self.sidebarRight.show();
    };

    //initial the side bar
    this.sidebarRight = $("#rightsider").sidebar();

    //initial the text box
    this.demoTextbox = $("#showCustomTextBox").cTextbox({
        attribute: {
            id: "txtDemo",
            required: true,
            tip: "Please input some text in here",
            validateType: CUICore.validateType.email,
            minlength: 3,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });

    //initial dropdown list
    this.demoDropdownList = $("#showCustomDropdownlist").cDropdownList({
        tip: "Please select a account.",
        data: { "v-cozou": "Conjee", "v-xc": "Chen Xi", "v-olzhao": "Zhao YuanQi" },
        selected: "v-xc",
        attribute: {
            id: "ddlDemo",
            required: true,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });

    //initial checkbox
    this.demoCheckBox = $("#showCustomCheckBox").cCheckbox({
        tip: "Check Box",
        attribute: {
            id: "ckbDemo",
            required: true,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });
    this.demoRadioButton = $("#showCustomRadioButton").cRadioGroup({
        data: { "v-cozou": "Conjee", "v-xc": "Chen Xi", "v-olzhao": "Zhao YuanQi" },
        attribute: {
            name: "rdbDemoGroup",
            required: true,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });
    this.demoRadioButton = $("#showCustomRadioButton1").cRadioGroup({
        data: { "v-cozou": "Conjee", "v-xc": "Chen Xi", "v-olzhao": "Zhao YuanQi" },
        selected: "v-cozou",
        attribute: {
            name: "rdbDemoGroup1",
            required: true,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });
    this.demoTextArea = $("#showCustomTextArea").cTextarea({
        attribute: {
            id: "txtareaDemo",
            required: true,
            OnValidateError: "error",
            onChanged: "onchanged"
        }
    });
    this.demoButton = $("#showCustomButton").cButton({
        attribute: {
            id: "btnDemo",
            onItemClick: "submit"
        }
    });
}
demonPage.prototype = new CUIPage();

$(document).ready(function () {
    //inherit the CUIPage
    var currentPage = new demonPage();
    currentPage.InitialPage();
});
